##########
#
#	iLvl 372
#
##########
#Bell of Enraging Resonance (heroic)
$buff->{92318} = {
				name => "Dire Magic",
				lasts => 20,
				fallsoff => 0,
				cd => 100,
				offcd => 0,
				chance => 0.3,
				upsince => 0,
				uptime => 0,
			};
$od{65053} = sub {
	if ($buff->{92318}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{92318}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Dire Magic\n", $now));
			$buff->{92318}->{fallsoff} = sprintf("%.4f", $now + $buff->{92318}->{lasts});
			$buff->{92318}->{offcd} = sprintf("%.4f", $now + $buff->{92318}->{cd});
			$buff->{92318}->{upsince} = $now;
			$event = [$buff->{92318}->{fallsoff}, \&fa92318];
			push(@queue, $event);
			$buff_sp += 2178;
			calcStatsDamage();
		}
	}
};
sub fa92318 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Dire Magic\n", $now));
	$buff->{92318}->{uptime} += sprintf("%.4f", $now - $buff->{92318}->{upsince});
	$buff_sp -= 2178;
	calcStatsDamage();
}

#Heart of Ignacious (heroic)
$buff->{92325} = {
				name => "Heart's Revelation",
				lasts => 15,
				fallsoff => 0,
				stacks => 0,
				upsince => 0,
				uptime => 0,
			};
$buff->{92328} = {
				name => "Heart's Judgement",
				lasts => 20,
				fallsoff => 0,
				cd => 120,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$od{65110} = sub {
	if ($buff->{92325}->{stacks} == 0) { $buff->{92325}->{upsince} = $now; }
	$buff_sp += 87;
	$buff->{92325}->{stacks} += 1;
	if ($buff->{92325}->{stacks} > 5) {
		$buff_sp -= 87;
		$buff->{92325}->{stacks} = 5;
		clog(sprintf("%.4f: SPELL_AURA_REFRESHED: Heart's Revelation (5)\n", $now));
		$buff->{92325}->{fallsoff} = sprintf("%.4f", $now + $buff->{92325}->{lasts});
	} else {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED_DOSE: Heart's Revelation (%.0f)\n", $now, $buff->{92325}->{stacks}));
		$buff->{92325}->{fallsoff} = sprintf("%.4f", $now + $buff->{92325}->{lasts});
		calcStatsDamage();
	}
};
$oc{65110} = sub {
	if (($buff->{92328}->{offcd} < $now) && ($buff->{92325}->{stacks} == 5)) {
		$buff->{92325}->{stacks} = 0;
		$buff->{92325}->{uptime} += sprintf("%.4f", $now - $buff->{92325}->{upsince});
		clog(sprintf("%.4f: SPELL_AURA_REMOVED: Heart's Revelation\n", $now));
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Heart's Judgement (5)\n", $now));
		$buff->{92328}->{fallsoff} = sprintf("%.4f", $now + $buff->{92328}->{lasts});
		$buff->{92328}->{offcd} = sprintf("%.4f", $now + $buff->{92328}->{cd});
		$buff->{92328}->{upsince} = $now;
		$event = [$buff->{92328}->{fallsoff}, \&fa92328];
		push(@queue, $event);
		$buff_sp -= 435;
		$buff_haste += 1815;
		calcStatsDamage();
	}
};
sub fa92328 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Heart's Judgement\n", $now));
	$buff->{92328}->{uptime} += sprintf("%.4f", $now - $buff->{92328}->{upsince});
	$buff_haste -= 1815;
	calcStatsDamage();
}

#Theralion's Mirror (heroic)
$buff->{92320} = {
				name => "Revelation",
				lasts => 20,
				fallsoff => 0,
				cd => 100,
				offcd => 0,
				chance => 0.1,
				upsince => 0,
				uptime => 0,
			};
$ocf{65105} = sub {
	if ($buff->{92320}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{92320}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Revelation\n", $now));
			$buff->{92320}->{fallsoff} = sprintf("%.4f", $now + $buff->{92320}->{lasts});
			$buff->{92320}->{offcd} = sprintf("%.4f", $now + $buff->{92320}->{cd});
			$buff->{92320}->{upsince} = $now;
			$event = [$buff->{92320}->{fallsoff}, \&fa92320];
			push(@queue, $event);
			$buff_mast += 2178;
			calcStatsDamage();
		}
	}
};
sub fa92320 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Revelation\n", $now));
	$buff->{92320}->{uptime} += sprintf("%.4f", $now - $buff->{92320}->{upsince});
	$buff_mast -= 2178;
	calcStatsDamage();
}

##########
#
#	iLvL 359
#
##########
#Bell of Enraging Resonance (normal)
$buff->{91007} = {
				name => "Dire Magic",
				lasts => 20,
				fallsoff => 0,
				cd => 100,
				offcd => 0,
				chance => 0.3,
				upsince => 0,
				uptime => 0,
			};
$od{59326} = sub {
	if ($buff->{91007}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{91007}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Dire Magic\n", $now));
			$buff->{91007}->{fallsoff} = sprintf("%.4f", $now + $buff->{91007}->{lasts});
			$buff->{91007}->{offcd} = sprintf("%.4f", $now + $buff->{91007}->{cd});
			$buff->{91007}->{upsince} = $now;
			$event = [$buff->{91007}->{fallsoff}, \&fa91007];
			push(@queue, $event);
			$buff_sp += 1926;
			calcStatsDamage();
		}
	}
};
sub fa91007 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Dire Magic\n", $now));
	$buff->{91007}->{uptime} += sprintf("%.4f", $now - $buff->{91007}->{upsince});
	$buff_sp -= 1926;
	calcStatsDamage();
}

#Darkmoon Card: Volcano
$buff->{89091} = {
				name => "Volcanic Destruction",
				lasts => 12,
				fallsoff => 0,
				cd => 60,
				offcd => 0,
				chance => 0.3,
				upsince => 0,
				uptime => 0,
			};
$od{62047} = sub {
	if ($buff->{89091}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{89091}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Volcanic Destruction\n", $now));
			$buff->{89091}->{fallsoff} = sprintf("%.4f", $now + $buff->{89091}->{lasts});
			$buff->{89091}->{offcd} = sprintf("%.4f", $now + $buff->{89091}->{cd});
			$buff->{89091}->{upsince} = $now;
			$roll = rand;
			if ($roll > $hitcap - $hit) {
				$roll = rand;
				if ($roll < $crit) {
					clog(sprintf("%.4f: SPELL_DAMAGE_CRIT: Volcanic Destruction\n", $now));
					$spell->{trinket}->{ccrit} += 1;
					$spell->{trinket}->{cdmg} += (1200 + 0.1 * $spellpower) * (1 + $crit * 0.5) * (1 + $buff_em * 0.15);
				} else {
					clog(sprintf("%.4f: SPELL_DAMAGE: Volcanic Destruction\n", $now));
					$spell->{trinket}->{chit} += 1;
					$spell->{trinket}->{cdmg} += (1200 + 0.1 * $spellpower) * (1 + $buff_em * 0.15);
				}
			} else {
				clog(sprintf("%.4f: SPELL_MISS: Volcanic Destruction\n", $now));
				$spell->{trinket}->{cmiss} += 1;
			}
			$event = [$buff->{89091}->{fallsoff}, \&fa89091];
			push (@queue, $event);
			$buff_int += 1600;
			#$buff_int += 1600 * 1.05 * (1 + $mailspec * 0.05);
			#$buff_sp += 1600 * 1.05 * (1 + $mailspec * 0.05);
			calcStatsDamage();
		}
	}
};
sub fa89091 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Volcanic Destruction\n", $now));
	$buff->{89091}->{uptime} += sprintf("%.4f", $now - $buff->{89091}->{upsince});
	$buff_int -= 1600;
	#$buff_int -= 1600 * 1.05 * (1 + $mailspec * 0.05);
	#$buff_sp -= 1600 * 1.05 * (1 + $mailspec * 0.05);
	calcStatsDamage();
}

#Heart of Ignacious (normal)
$buff->{91027} = {
				name => "Heart's Revelation",
				lasts => 15,
				fallsoff => 0,
				stacks => 0,
				upsince => 0,
				uptime => 0,
			};
$buff->{91041} = {
				name => "Heart's Judgement",
				lasts => 20,
				fallsoff => 0,
				cd => 120,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$od{59514} = sub {
	if ($buff->{91027}->{stacks} == 0) { $buff->{91027}->{upsince} = $now; }
	$buff->{91027}->{stacks} += 1;
	$buff_sp += 77;
	if ($buff->{91027}->{stacks} > 5) {
		$buff_sp -= 77;
		$buff->{91027}->{stacks} = 5;
		clog(sprintf("%.4f: SPELL_AURA_REFRESHED: Heart's Revelation (5)\n", $now));
		$buff->{91027}->{fallsoff} = sprintf("%.4f", $now + $buff->{91027}->{lasts});
	} else {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED_DOSE: Heart's Revelation (%.0f)\n", $now, $buff->{91027}->{stacks}));
		$buff->{91027}->{fallsoff} = sprintf("%.4f", $now + $buff->{91027}->{lasts});
		calcStatsDamage();
	}
};
$oc{59514} = sub {
	if (($buff->{91041}->{offcd} < $now) && ($buff->{91027}->{stacks} == 5)) {
		$buff->{91027}->{stacks} = 0;
		$buff->{91027}->{uptime} += sprintf("%.4f", $now - $buff->{91027}->{upsince});
		clog(sprintf("%.4f: SPELL_AURA_REMOVED: Heart's Revelation\n", $now));
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Heart's Judgement (5)\n", $now));
		$buff->{91041}->{fallsoff} = sprintf("%.4f", $now + $buff->{91041}->{lasts});
		$buff->{91041}->{offcd} = sprintf("%.4f", $now + $buff->{91041}->{cd});
		$buff->{91041}->{upsince} = $now;
		$event = [$buff->{91041}->{fallsoff}, \&fa91041];
		push(@queue, $event);
		$buff_sp -= 385;
		$buff_haste += 1605;
		calcStatsDamage();
	}
};
sub fa91041 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Heart's Judgement\n", $now));
	$buff->{91041}->{uptime} += sprintf("%.4f", $now - $buff->{91041}->{upsince});
	$buff_haste -= 1605;
	calcStatsDamage();
}

#Soul Casket
$buff->{91019} = {
				name => "Soul Power",
				lasts => 20,
				fallsoff => 0,
				cd => 120,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$oc{58183} = sub {
	if ($buff->{91019}->{offcd} < $now) {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Soul Power\n", $now));
		$buff->{91019}->{fallsoff} = sprintf("%.4f", $now + $buff->{91019}->{lasts});
		$buff->{91019}->{offcd} = sprintf("%.4f", $now + $buff->{91019}->{cd});
		$buff->{91019}->{upsince} = $now;
		$event = [$buff->{91019}->{fallsoff}, \&fa91019];
		push(@queue, $event);
		$buff_sp += 1926;
		calcStatsDamage();
	}
};
sub fa91019 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Soul Power\n", $now));
	$buff->{91019}->{uptime} += sprintf("%.4f", $now - $buff->{91019}->{upsince});
	$buff_sp -= 1926;
	calcStatsDamage();
}

#Stump of Time
$buff->{91047} = {
				name => "Battle Magic",
				lasts => 15,
				fallsoff => 0,
				cd => 75,
				offcd => 0,
				chance => 0.1,
				upsince => 0,
				uptime => 0,
			};
$ocf{62470} = sub {
	if ($buff->{91047}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{91047}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Battle Magic\n", $now));
			$buff->{91047}->{fallsoff} = sprintf("%.4f", $now + $buff->{91047}->{lasts});
			$buff->{91047}->{offcd} = sprintf("%.4f", $now + $buff->{91047}->{cd});
			$buff->{91047}->{upsince} = $now;
			$event = [$buff->{91047}->{fallsoff}, \&fa91047];
			push(@queue, $event);
			$buff_sp += 1926;
			calcStatsDamage();
		}
	}
};
$ocf{62465} = $ocf{62470};
sub fa91047 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Battle Magic\n", $now));
	$buff->{91047}->{uptime} += sprintf("%.4f", $now - $buff->{91047}->{upsince});
	$buff_sp -= 1926;
	calcStatsDamage();
}

##########
#
#	iLvl 346
#
##########
#Anhuur's Hymnal (heroic) (seems to be messing things up)
$buff->{90992} = {
				name => "Hymn of Power",
				lasts => 10,
				fallsoff => 0,
				cd => 50,
				offcd => 0,
				chance => 0.1,
				upsince => 0,
				uptime => 0,
			};
$ocf{56407} = sub {
	if ($buff->{90992}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{90992}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Hymn of Power\n", $now));
			$buff->{90992}->{fallsoff} = sprintf("%.4f", $now + $buff->{90992}->{lasts});
			$buff->{90992}->{offcd} = sprintf("%.4f", $now + $buff->{90992}->{cd});
			$buff->{90992}->{upsince} = $now;
			$event = [$buff->{90992}->{fallsoff}, $fa90992];
			push(@queue, $event);
			$buff_sp += 1710;
			calcStatsDamage();
		}
	}
};
$fa90992 = sub {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Hymn of Power\n", $now));
	$buff->{90992}->{uptime} += sprintf("%.4f", $now - $buff->{90992}->{upsince});
	$buff_sp -= 1710;
	calcStatsDamage();
};

#Figurine - Jeweled Serpent
$buff->{73551} = {
				name => "Jeweled Serpent",
				lasts => 20,
				fallsoff => 0,
				cd => 120,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$oc{52353} = sub {
	if ($buff->{73551}->{offcd} < $now) {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Jeweled Serpent\n", $now));
		$buff->{73551}->{fallsoff} = sprintf("%.4f", $now + $buff->{73551}->{lasts});
		$buff->{73551}->{offcd} = sprintf("%.4f", $now + $buff->{73551}->{cd});
		$buff->{73551}->{upsince} = $now;
		$event = [$buff->{73551}->{fallsoff}, \&fa73551];
		push(@queue, $event);
		$buff_sp += 1425;
		calcStatsDamage();
	}
};
sub fa73551 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Jeweled Serpent\n", $now));
	$buff->{73551}->{uptime} += sprintf("%.4f", $now - $buff->{73551}->{upsince});
	$buff_sp -= 1425;
	calcStatsDamage();
}

#Gale of Shadows (heroic)
$buff->{90985} = {
				name => "Dead Winds",
				lasts => 15,
				fallsoff => 0,
				stacks => 0,
				upsince => 0,
				uptime => 0,
			};
$op{56462} = sub {
	if ($buff->{90985}->{stacks} == 0) { $buff->{90985}->{upsince} = $now; }
	$buff->{90985}->{stacks} += 1;
	$buff_sp += 17;
	if ($buff->{90985}->{stacks} > 20) {
		$buff_sp -= 17;
		$buff->{90985}->{stacks} = 20;
		clog(sprintf("%.4f: SPELL_AURA_REFRESHED: Dead Winds (20)\n", $now));
		$buff->{90985}->{fallsoff} = sprintf("%.4f", $now + $buff->{90985}->{lasts});
	} else {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED_DOSE: Dead Winds (%.0f)\n", $now, $buff->{90985}->{stacks}));
		$buff->{90985}->{fallsoff} = sprintf("%.4f", $now + $buff->{90985}->{lasts});
		calcStatsDamage();
	}
};

#Sea Star (heroic)
$buff->{91136} = {
				name => "Leviathan",
				lasts => 20,
				fallsoff => 0,
				cd => 120,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$oc{56290} = sub {
	if ($buff->{91136}->{offcd} < $now) {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Leviathan\n", $now));
		$buff->{91136}->{fallsoff} = sprintf("%.4f", $now + $buff->{91136}->{lasts});
		$buff->{91136}->{offcd} = sprintf("%.4f", $now + $buff->{91136}->{cd});
		$buff->{91136}->{upsince} = $now;
		$event = [$buff->{91136}->{fallsoff}, \&fa91136];
		push(@queue, $event);
		$buff_sp += 1425;
		calcStatsDamage();
	}
};
sub fa91136 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Leviathan\n", $now));
	$buff_sp -= 1425;
	calcStatsDamage();
}

#Sorrowsong (heroic) (assumes 35% health equals 35% fighttime)
$buff->{91002} = {
				name => "Crescendo of Suffering",
				lasts => 10,
				fallsoff => 0,
				cd => 20,
				offcd => 0,
				upsince => 0,
				uptime => 0,
			};
$od{56400} = sub {
	if (($buff->{91002}->{offcd} < $now) && ($now > 0.65 * $fighttime)) {
		clog(sprintf("%.4f: SPELL_AURA_APPLIED: Crescendo of Suffering\n", $now));
		$buff->{91002}->{fallsoff} = sprintf("%.4f", $now + $buff->{91002}->{lasts});
		$buff->{91002}->{offcd} = sprintf("%.4f", $now + $buff->{91002}->{cd});
		$buff->{91002}->{upsince} = $now;
		$event = [$buff->{91002}->{fallsoff}, \&fa91002];
		push(@queue, $event);
		$buff_sp += 1710;
		calcStatsDamage();
	}
};
sub fa91002 {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Crescendo of Suffering\n", $now));
	$buff->{91002}->{uptime} += sprintf("%.4f", $now - $buff->{91002}->{upsince});
	$buff_sp -= 1710;
	calcStatsDamage();
}
#Witching Hourglass (heroic)
$buff->{90887} = {
				name => "Witching Hour",
				lasts => 15,
				fallsoff => 0,
				cd => 75,
				offcd => 0,
				chance => 0.1,
				upsince => 0,
				uptime => 0,
			};
$ocf{56320} = sub {
	if ($buff->{90887}->{offcd} < $now) {
		$roll = rand;
		if ($roll < $buff->{90887}->{chance}) {
			clog(sprintf("%.4f: SPELL_AURA_APPLIED: Witching Hour\n", $now));
			$buff->{90887}->{fallsoff} = sprintf("%.4f", $now + $buff->{90887}->{lasts});
			$buff->{90887}->{offcd} = sprintf("%.4f", $now + $buff->{90887}->{cd});
			$buff->{90887}->{upsince} = $now;
			$event = [$buff->{90887}->{fallsoff}, $fa90887];
			push(@queue, $event);
			$buff_haste += 1710;
			calcStatsDamage();
		}
	}
};
$fa90887 = sub {
	clog(sprintf("%.4f: SPELL_AURA_REMOVED: Witching Hour\n", $now));
	$buff->{90887}->{uptime} += sprintf("%.4f", $now - $buff->{90887}->{upsince});
	$buff_haste -= 1710;
	calcStatsDamage();
};